home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Wissenschaft & Technik / Object Plant ƒ / 68k Object Plant / 68k Object Plant.rsrc / TEXT_128_EPS prep.txt < prev    next >
Text File  |  1997-02-27  |  49KB  |  1,859 lines

  1. %%DocumentFonts: Helvetica 
  2. %%DocumentNeededFonts: Helvetica 
  3. %%IncludeFont: Helvetica 
  4. /RE
  5. {
  6.     findfont begin
  7.     currentdict dup length dict begin
  8.     {
  9.         1 index /FID ne {def}{pop pop}ifelse
  10.     }forall
  11.     /FontName exch def dup length 0 ne
  12.     {
  13.         /Encoding Encoding 256 array copy def
  14.         0 exch
  15.         {
  16.             dup type /nametype eq
  17.             {
  18.                 Encoding 2 index 2 index put
  19.                 pop 1 add
  20.             }
  21.             {
  22.                 exch pop
  23.             }ifelse
  24.         }forall
  25.     }if pop
  26.     currentdict dup end end
  27.     /FontName get exch definefont pop
  28. } bind def
  29.  
  30. /stdencoding [
  31. 39/quotesingle 96/grave 128/Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis
  32. /Udieresis/aacute/agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute
  33. /egrave/ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde
  34. /oacute/ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex
  35. /udieresis/dagger/degree/cent/sterling/section/bullet/paragraph/germandbls
  36. /registered/copyright/trademark/acute/dieresis/.notdef/AE/Oslash
  37. /.notdef/plusminus/.notdef/.notdef/yen/mu/.notdef/.notdef
  38. /.notdef/.notdef/.notdef/ordfeminine/ordmasculine/.notdef/ae/oslash
  39. /questiondown/exclamdown/logicalnot/.notdef/florin/.notdef/.notdef
  40. /guillemotleft/guillemotright/ellipsis/.notdef/Agrave/Atilde/Otilde/OE/oe
  41. /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide
  42. /.notdef/ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright
  43. /fi/fl/daggerdbl/periodcentered/quotesinglbase/quotedblbase/perthousand
  44. /Acircumflex/Ecircumflex/Aacute/Edieresis/Egrave/Iacute/Icircumflex
  45. /Idieresis/Igrave/Oacute/Ocircumflex/.notdef/Ograve/Uacute/Ucircumflex
  46. /Ugrave/dotlessi/circumflex/tilde/macron/breve/dotaccent/ring/cedilla
  47. /hungarumlaut/ogonek/caron
  48. ] def
  49. stdencoding /_Helvetica /Helvetica RE
  50. stdencoding /_Helvetica-Oblique /Helvetica-Oblique RE
  51. stdencoding /_Helvetica-Bold /Helvetica-Bold RE
  52. stdencoding /_Helvetica-BoldOblique /Helvetica-BoldOblique RE
  53.  
  54. /Monaco10 /_Helvetica findfont 10 scalefont def
  55. /MonacoI10 /_Helvetica-Oblique findfont 10 scalefont def
  56. /MonacoB10 /_Helvetica-Bold findfont 10 scalefont def
  57. /MonacoBI10 /_Helvetica-BoldOblique findfont 10 scalefont def
  58. /Monaco9 /_Helvetica findfont 9 scalefont def
  59. /MonacoI9 /_Helvetica-Oblique findfont 9 scalefont def
  60.  
  61. /defaultHeight 30 def /ifDefaultHeight 40 def /defaultWidth 60 def
  62. /pointSize 3 def /diamondWidth 8 def /pyramidWidth 18 def
  63. /eventBoxWidth 9 def
  64.  
  65. /drawClassBox    % oper1 ... opern noOfOpers attr1 ... attrn noOfAttrs name abstract nested
  66. {
  67.     50 dict begin
  68.     /nested exch def /abstract exch def
  69.     /name exch def
  70.  
  71.     false abstract eq { MonacoB10 setfont }{ MonacoBI10 setfont } ifelse
  72.  
  73.     /maxwidth name stringwidth pop def
  74.     /boxwidth defaultWidth def
  75.  
  76.     /noOfAttr exch def /AttrArray noOfAttr array def /index noOfAttr 1 sub def {
  77.         index -1 eq { exit } if
  78.         AttrArray index 3 -1 roll put
  79.         /index index 1 sub def
  80.     } loop
  81.  
  82.     /noOfOper exch def /OperArray noOfOper array def /index noOfOper 1 sub def {
  83.         index -1 eq { exit } if
  84.         OperArray index 3 -1 roll put
  85.         /index index 1 sub def
  86.     } loop
  87.  
  88.     % Set font size for attributes an operations while checking boxwidth
  89.     false abstract eq { Monaco9 setfont }{ MonacoI9 setfont } ifelse
  90.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  91.     AttrArray {
  92.         stringwidth pop 8 add dup
  93.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  94.     } forall
  95.     OperArray {
  96.         stringwidth pop 8 add dup
  97.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  98.     } forall
  99.  
  100.     % Set back font size for the class name
  101.     false abstract eq { MonacoB10 setfont }{ MonacoBI10 setfont } ifelse
  102.     maxwidth boxwidth 6 sub gt { /boxwidth maxwidth 6 add def } if
  103.     noOfAttr 0 ne { /boxheight noOfAttr 12 mul 26 add def } if
  104.     noOfOper 0 ne { noOfAttr 0 ne { /boxheight boxheight 6 add noOfOper 12 mul add def }
  105.                                     { /boxheight noOfOper 12 mul 26 add def } ifelse } if
  106.     noOfOper 0 eq { noOfAttr 0 eq { /boxheight defaultHeight def } if } if
  107.     boxheight defaultHeight lt { /boxheight defaultHeight def } if
  108.     nested true eq { [3] 0 setdash } if
  109.     currentpoint boxwidth 0 rlineto
  110.     0 boxheight neg rlineto
  111.     boxwidth neg 0 rlineto closepath gsave 1 setgray fill grestore stroke
  112.     nested true eq { [] 0 setdash } if
  113.  
  114.     noOfAttr 0 ne { leftmargin topmargin -18 add moveto boxwidth 0 rlineto stroke } if
  115.  
  116.     noOfOper 0 ne
  117.     {
  118.         newpath noOfAttr 0 ne { leftmargin topmargin -24 add noOfAttr -12 mul add moveto }
  119.                                     { leftmargin topmargin -20 add moveto }ifelse
  120.         boxwidth 0 rlineto stroke
  121.     }if
  122.     moveto currentpoint
  123.     boxwidth name stringwidth pop sub 2 div -14 rmoveto name show
  124.  
  125.     false abstract eq { Monaco9 setfont }{ MonacoI9 setfont } ifelse
  126.     currentpoint /index 0 def
  127.     AttrArray
  128.     { 
  129.         leftmargin 8 add topmargin moveto
  130.         0 -12 index mul -30 add rmoveto show
  131.         /index index 1 add def
  132.     } forall
  133.     moveto currentpoint /index 0 def
  134.     OperArray
  135.     {
  136.         leftmargin 8 add topmargin moveto
  137.         noOfAttr 0 ne { 0 -12 index mul noOfAttr -12 mul add 38 sub rmoveto }
  138.         { 0 -12 index mul 32 sub rmoveto }ifelse show
  139.          /index index 1 add def
  140.     } forall
  141.     leftmargin boxwidth add topmargin boxheight sub
  142.     end
  143. } def
  144. /drawInterfaceBox    % oper1 ... opern noOfOpers attr1 ... attrn noOfAttrs name drawInterfaceBox
  145. {
  146.     50 dict begin
  147.     /name exch def
  148.  
  149.     MonacoB10 setfont
  150.  
  151.     /maxwidth name stringwidth pop def
  152.     /boxwidth defaultWidth def
  153.  
  154.     /noOfAttr exch def /AttrArray noOfAttr array def /index noOfAttr 1 sub def {
  155.         index -1 eq { exit } if
  156.         AttrArray index 3 -1 roll put
  157.         /index index 1 sub def
  158.     } loop
  159.  
  160.     /noOfOper exch def /OperArray noOfOper array def /index noOfOper 1 sub def {
  161.         index -1 eq { exit } if
  162.         OperArray index 3 -1 roll put
  163.         /index index 1 sub def
  164.     } loop
  165.  
  166.     % Set font size for attributes an operations while checking boxwidth
  167.     Monaco9 setfont
  168.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  169.     AttrArray {
  170.         stringwidth pop 8 add dup
  171.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  172.     } forall
  173.     OperArray {
  174.         stringwidth pop 8 add dup
  175.         maxwidth gt { /maxwidth exch def }{ pop } ifelse
  176.     } forall
  177.  
  178.     MonacoB10 setfont
  179.     maxwidth boxwidth 6 sub gt { /boxwidth maxwidth 6 add def } if
  180.     noOfAttr 0 ne { /boxheight noOfAttr 12 mul 36 add def } if
  181.     noOfOper 0 ne { noOfAttr 0 ne { /boxheight boxheight 6 add noOfOper 12 mul add def }
  182.                                     { /boxheight noOfOper 12 mul 36 add def } ifelse } if
  183.     noOfOper 0 eq { noOfAttr 0 eq { /boxheight ifDefaultHeight def } if } if
  184.     boxheight ifDefaultHeight lt { /boxheight ifDefaultHeight def } if
  185.     currentpoint boxwidth 0 rlineto
  186.     0 boxheight  neg  rlineto
  187.     boxwidth neg 0 rlineto closepath gsave 1 setgray fill grestore stroke
  188.  
  189.     noOfAttr 0 ne { leftmargin topmargin -28 add moveto boxwidth 0 rlineto stroke } if
  190.  
  191.     noOfOper 0 ne
  192.     {
  193.         newpath noOfAttr 0 ne { leftmargin topmargin -34 add noOfAttr -12 mul add moveto }
  194.                                     { leftmargin topmargin -28 add moveto }ifelse
  195.         boxwidth 0 rlineto stroke
  196.     }if
  197.     moveto currentpoint
  198.     boxwidth name stringwidth pop sub 2 div -24 rmoveto name show
  199.     leftmargin topmargin moveto
  200.     boxwidth (¬´interface¬ª) stringwidth pop sub 2 div -14 rmoveto (¬´interface¬ª) show
  201.  
  202.     Monaco9 setfont
  203.     currentpoint /index 0 def
  204.     AttrArray
  205.     { 
  206.         leftmargin 8 add topmargin 10 sub moveto
  207.         0 -12 index mul -30 add rmoveto show
  208.         /index index 1 add def
  209.     } forall
  210.     moveto currentpoint /index 0 def
  211.     OperArray
  212.     {
  213.         leftmargin 8 add topmargin 10 sub moveto
  214.         noOfAttr 0 ne { 0 -12 index mul noOfAttr -12 mul add 38 sub rmoveto }
  215.         { 0 -12 index mul 32 sub rmoveto }ifelse show
  216.          /index index 1 add def
  217.     } forall
  218.     leftmargin boxwidth add topmargin boxheight sub
  219.     end
  220. } def
  221.  
  222. /drawAssoc    % pointn ... point1 noOfPoints branchRole branchMultText branchMult branchQualPos branchQual baseRole baseMultText baseMult baseQualPos baseQual name
  223. {
  224.     50 dict begin
  225.     Monaco9 setfont
  226.  
  227.     /name exch def /baseQual exch def /baseQualPos exch def /baseMult exch def /baseMultText exch def /baseRole exch def
  228.     /branchQual exch def /branchQualPos exch def /branchMult exch def /branchMultText exch def /branchRole exch def
  229.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  230.     {
  231.         index noOfPoints 2 mul eq { exit } if
  232.         pntArray index 3 -1 roll put
  233.         /index index 1 add def
  234.     } loop
  235.  
  236. % Get the base qualifier's position
  237.     
  238.     /baseQualTW baseQual stringwidth pop def
  239.     /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  240.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  241.     /connect.h p1.h def
  242.     /connect.v p1.v def
  243.     baseQualPos 1 eq
  244.     {    % to the left of the first point
  245.         baseMult 1 eq {
  246.             /connect.h connect.h pointSize 2 div 2 add add def
  247.         } if
  248.         baseMult 2 eq {
  249.             /connect.h connect.h pointSize 2 div 2 add add def
  250.         } if
  251.     } if
  252.     baseQualPos 2 eq
  253.     {    % above the first point
  254.         baseMult 1 eq {
  255.             /connect.v connect.v pointSize 2 div 2 add sub def
  256.         } if
  257.         baseMult 2 eq {
  258.             /connect.v connect.v pointSize 2 div 2 add sub def
  259.         } if
  260.     } if
  261.     baseQualPos 3 eq
  262.     {    % to the right of the first point
  263.         baseMult 1 eq {
  264.             /connect.h connect.h pointSize 2 div 2 add sub def
  265.         } if
  266.         baseMult 2 eq {
  267.             /connect.h connect.h pointSize 2 div 2 add sub def
  268.         } if
  269.     } if
  270.     baseQualPos 4 eq
  271.     {    % below the first point
  272.         baseMult 1 eq {
  273.             /connect.v connect.v pointSize 2 div 2 add add def
  274.         } if
  275.         baseMult 2 eq {
  276.             /connect.v connect.v pointSize 2 div 2 add add def
  277.         } if
  278.     } if
  279.     baseQualPos 1 eq
  280.     {    % to the left of the first point
  281.         /p1.h connect.h baseQualTW 5 add sub def
  282.         /p1.v connect.v 3 sub def 
  283.     } if
  284.     baseQualPos 2 eq
  285.     {    % above the first point
  286.         /p1.h connect.h baseQualTW 2 div sub def
  287.         /p1.v connect.v 4 add def 
  288.     } if
  289.     baseQualPos 3 eq
  290.     {    % to the right of the first point
  291.         /p1.h connect.h 6 add def
  292.         /p1.v connect.v 3 sub def 
  293.     } if
  294.     baseQualPos 4 eq
  295.     {    % below the first point
  296.         /p1.h connect.h baseQualTW 2 div sub def
  297.         /p1.v connect.v 10 sub def
  298.     } if
  299.     /baseQualText.h p1.h def
  300.     /baseQualText.v p1.v def
  301.  
  302.     /lineConnect.h connect.h def
  303.     /lineConnect.v connect.v def
  304.  
  305. % Determine the qualifiers rectangle size
  306.     baseQualTW 0 ne
  307.     {
  308.         baseQualPos 1 eq
  309.         {    % to the left of the first class
  310.             /RectRight connect.h def
  311.             /RectLeft baseQualText.h 5 sub def
  312.             /lineConnect.h RectLeft def
  313.             /RectTop baseQualText.v 12 add def
  314.             /RectBottom RectTop 16 sub def
  315.         } if
  316.         baseQualPos 3 eq
  317.         {    % to the right of the first class
  318.             /RectLeft connect.h def
  319.             /RectRight baseQualText.h baseQualTW 5 add add def
  320.             /lineConnect.h RectRight def
  321.             /RectTop baseQualText.v 12 add def
  322.             /RectBottom RectTop 16 sub def
  323.         } if
  324.         baseQualPos 2 eq
  325.         {    % above the first point
  326.             /RectBottom connect.v def
  327.             /RectTop RectBottom 16 add def
  328.             /lineConnect.v RectTop def
  329.             /RectLeft baseQualText.h 4 sub def
  330.             /RectRight RectLeft baseQualTW 9 add add def
  331.         } if
  332.         baseQualPos 4 eq
  333.         {    % below the first point
  334.             /RectTop connect.v def
  335.             /RectBottom RectTop 16 sub def
  336.             /lineConnect.v RectBottom def
  337.             /RectLeft baseQualText.h 4 sub def
  338.             /RectRight RectLeft baseQualTW add 9 add def
  339.         } if
  340.         RectLeft RectTop moveto
  341.         RectRight RectTop lineto
  342.         RectRight RectBottom lineto
  343.         RectLeft RectBottom lineto
  344.         closepath stroke
  345.         newpath
  346.         baseQualText.h baseQualText.v moveto
  347.         baseQual show
  348.     } if
  349.  
  350.     newpath 1 setlinewidth 0 setgray
  351.     /index 0 def
  352.     {
  353.         index noOfPoints eq { exit } if
  354.         pntArray index 2 mul 1 add get pntArray index 2 mul get
  355.         index noOfPoints 1 sub eq { pop pop lineConnect.h lineConnect.v } if
  356.         index 0 eq { moveto }{ lineto } ifelse
  357.         /index index 1 add def
  358.     } loop
  359.     stroke
  360.     /circle.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  361.     /circle.v pntArray noOfPoints 1 sub 2 mul get def
  362.     baseQualTW 0 ne
  363.     {
  364.         baseQualPos 1 eq
  365.         {    % to the left of the first class
  366.             /circle.h circle.h baseQualTW 9 add sub def
  367.         } if
  368.         baseQualPos 3 eq
  369.         {    % to the right of the first class
  370.             /circle.h circle.h baseQualTW 11 add add def
  371.         } if
  372.         baseQualPos 2 eq
  373.         {    % above the first point
  374.             /circle.v circle.v 16 add def
  375.         } if
  376.         baseQualPos 4 eq
  377.         {    % below the first point
  378.             /circle.v circle.v 16 sub def
  379.         } if
  380.     } if
  381.     circle.h circle.v
  382.     baseMult 1 eq {
  383.         % hollow circle
  384.         pointSize 0.5 sub 0 360 arc stroke
  385.         circle.h circle.v
  386.         pointSize 1 sub 0 360 arc 1 setgray fill
  387.     } if
  388.     baseMult 2 eq {
  389.         % filled circle
  390.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  391.     } if
  392.  
  393.     0 setgray /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  394.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  395.     /p2.h pntArray noOfPoints 2 sub 2 mul 1 add get def
  396.     /p2.v pntArray noOfPoints 2 sub 2 mul get def
  397.     /roletextwidth baseRole stringwidth pop def
  398.  
  399.     p1.h p2.h eq
  400.     { p1.v p2.v le
  401.         { p1.h 5 add p1.v 4 add baseQualTW 0 ne { 14 add } if }
  402.         { p1.h 5 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  403.     }
  404.     { p1.v p2.v eq
  405.         { p1.h p2.h gt
  406.                 { p1.h roletextwidth 5 add sub baseQualTW 0 ne { baseQualTW 9 add sub } if p1.v 10 sub }
  407.                 { p1.h 6 add baseQualTW 0 ne { baseQualTW 7 add add } if p1.v 10 sub } ifelse
  408.         }
  409.         {    p1.v p2.v le
  410.             {    p1.h p2.h gt
  411.                 { p1.h roletextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  412.                 { p1.h 6 add p1.v 4 add baseQualTW 0 ne { 14 add } if } ifelse
  413.             }
  414.             {    p1.h p2.h gt
  415.                 { p1.h roletextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if }
  416.                 { p1.h 6 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  417.             } ifelse
  418.         } ifelse
  419.     } ifelse
  420.     moveto baseRole show
  421.     /p1.h pntArray noOfPoints 1 sub 2 mul 1 add get def
  422.     /p1.v pntArray noOfPoints 1 sub 2 mul get def
  423.     /p2.h pntArray noOfPoints 2 sub 2 mul 1 add get def
  424.     /p2.v pntArray noOfPoints 2 sub 2 mul get def
  425.     /multtextwidth baseMultText stringwidth pop def
  426.  
  427.     p1.h p2.h eq
  428.     { p1.v p2.v le
  429.             {    p1.h multtextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  430.             {    p1.h multtextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  431.     }
  432.     { p1.v p2.v eq
  433.             { p1.h p2.h gt
  434.                     { p1.h multtextwidth 5 add sub baseQualTW 0 ne { baseQualTW 9 add sub } if p1.v 4 add }
  435.                     { p1.h 5 add baseQualTW 0 ne { baseQualTW 7 add add } if p1.v 4 add } ifelse
  436.             }
  437.             { p1.v p2.v le
  438.                     { p1.h p2.h gt
  439.                             { p1.h multtextwidth 5 add sub p1.v 4 add baseQualTW 0 ne { 14 add } if }
  440.                             { p1.h 5 add p1.v 4 add baseQualTW 0 ne { 14 add } if } ifelse
  441.                     }
  442.                     { p1.h p2.h gt
  443.                             { p1.h multtextwidth 5 add sub p1.v 10 sub baseQualTW 0 ne { 14 sub } if }
  444.                             { p1.h 5 add p1.v 10 sub baseQualTW 0 ne { 14 sub } if } ifelse
  445.                     } ifelse
  446.             } ifelse
  447.     } ifelse
  448.     moveto
  449.     baseMult 3 eq {
  450.         baseMultText show
  451.     } if
  452.  
  453.     newpath
  454.     % Get the branch qualifier's position
  455.  
  456.     /branchQualTW branchQual stringwidth pop def
  457.     /p1.h pntArray 1 get def
  458.     /p1.v pntArray 0 get def
  459.     /connect.h p1.h def
  460.     /connect.v p1.v def
  461.     branchQualPos 1 eq
  462.     {    % to the left of the first point
  463.         branchMult 1 eq {
  464.             /connect.h connect.h pointSize 2 div 2 add add def
  465.         } if
  466.         branchMult 2 eq {
  467.             /connect.h connect.h pointSize 2 div 2 add add def
  468.         } if
  469.         /p1.h connect.h branchQualTW 5 add sub def
  470.         /p1.v connect.v 3 sub def 
  471.     } if
  472.     branchQualPos 2 eq
  473.     {    % above the first point
  474.         branchMult 1 eq {
  475.             /connect.v connect.v pointSize 2 div 2 add sub def
  476.         } if
  477.         branchMult 2 eq {
  478.             /connect.v connect.v pointSize 2 div 2 add sub def
  479.         } if
  480.         /p1.h connect.h branchQualTW 2 div sub def
  481.         /p1.v connect.v 4 add def 
  482.     } if
  483.     branchQualPos 3 eq
  484.     {    % to the right of the first point
  485.         branchMult 1 eq {
  486.             /connect.h connect.h pointSize 2 div 2 add sub def
  487.         } if
  488.         branchMult 2 eq {
  489.             /connect.h connect.h pointSize 2 div 2 add sub def
  490.         } if
  491.         /p1.h connect.h 6 add def
  492.         /p1.v connect.v 3 sub def 
  493.     } if
  494.     branchQualPos 4 eq
  495.     {    % below the first point
  496.         branchMult 1 eq {
  497.             /connect.v connect.v pointSize 2 div 2 add add def
  498.         } if
  499.         branchMult 2 eq {
  500.             /connect.v connect.v pointSize 2 div 2 add add def
  501.         } if
  502.         /p1.h connect.h branchQualTW 2 div sub def
  503.         /p1.v connect.v 10 sub def
  504.     } if
  505.     /branchQualText.h p1.h def
  506.     /branchQualText.v p1.v def
  507.  
  508.     /lineConnect.h connect.h def
  509.     /lineConnect.v connect.v def
  510.  
  511. % Determine the qualifiers rectangle size
  512.     branchQualTW 0 ne
  513.     {
  514.         branchQualPos 1 eq
  515.         {    % to the left of the first class
  516.             /RectRight connect.h def
  517.             /RectLeft branchQualText.h 5 sub def
  518.             /lineConnect.h RectLeft def
  519.             /RectTop branchQualText.v 12 add def
  520.             /RectBottom RectTop 16 sub def
  521.         } if
  522.         branchQualPos 3 eq
  523.         {    % to the right of the first class
  524.             /RectLeft connect.h def
  525.             /RectRight branchQualText.h branchQualTW 5 add add def
  526.             /lineConnect.h RectRight def
  527.             /RectTop branchQualText.v 12 add def
  528.             /RectBottom RectTop 16 sub def
  529.         } if
  530.         branchQualPos 2 eq
  531.         {    % above the first point
  532.             /RectBottom connect.v def
  533.             /RectTop RectBottom 16 add def
  534.             /lineConnect.v RectTop def
  535.             /RectLeft branchQualText.h 4 sub def
  536.             /RectRight RectLeft branchQualTW 9 add add def
  537.         } if
  538.         branchQualPos 4 eq
  539.         {    % below the first point
  540.             /RectTop connect.v def
  541.             /RectBottom RectTop 16 sub def
  542.             /lineConnect.v RectBottom def
  543.             /RectLeft branchQualText.h 4 sub def
  544.             /RectRight RectLeft branchQualTW add 9 add def
  545.         } if
  546.         RectLeft RectTop moveto
  547.         RectRight RectTop lineto
  548.         RectRight RectBottom lineto
  549.         RectLeft RectBottom lineto
  550.         closepath gsave 1 setgray fill grestore stroke
  551.         newpath
  552.         branchQualText.h branchQualText.v moveto
  553.         branchQual show
  554.     } if
  555.     newpath
  556.     0 setgray
  557.     /circle.h pntArray 1 get def
  558.     /circle.v pntArray 0 get def
  559.     branchQualTW 0 ne
  560.     {
  561.         branchQualPos 1 eq
  562.         {    % to the left of the first class
  563.             /circle.h circle.h branchQualTW 9 add sub def
  564.         } if
  565.         branchQualPos 3 eq
  566.         {    % to the right of the first class
  567.             /circle.h circle.h branchQualTW 11 add add def
  568.         } if
  569.         branchQualPos 2 eq
  570.         {    % above the first point
  571.             /circle.v circle.v 16 add def
  572.         } if
  573.         branchQualPos 4 eq
  574.         {    % below the first point
  575.             /circle.v circle.v 16 sub def
  576.         } if
  577.     } if
  578.     circle.h circle.v
  579.     branchMult 1 eq {
  580.         % hollow circle
  581.         pointSize 0.5 sub 0 360 arc stroke
  582.         circle.h circle.v
  583.         pointSize 1 sub 0 360 arc 1 setgray fill
  584.     } if
  585.     branchMult 2 eq {
  586.         % filled circle
  587.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  588.     } if
  589.  
  590.     0 setgray
  591.     /p1.h pntArray 1 get def
  592.     /p1.v pntArray 0 get def
  593.     /p2.h pntArray 3 get def
  594.     /p2.v pntArray 2 get def
  595.     /roletextwidth branchRole stringwidth pop def
  596.  
  597.     p1.h p2.h eq
  598.     {    p1.v p2.v le
  599.         { p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if }
  600.         { p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  601.     }
  602.     { p1.v p2.v eq
  603.         {    p1.h p2.h gt
  604.             { p1.h roletextwidth 5 add sub branchQualTW 0 ne { branchQualTW 9 add sub } if p1.v 10 sub }
  605.             { p1.h 5 add branchQualTW 0 ne { branchQualTW 7 add add } if p1.v 10 sub } ifelse
  606.         }
  607.         {    p1.v p2.v le
  608.             {    p1.h p2.h gt
  609.                 {    p1.h roletextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  610.                 {    p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if } ifelse
  611.             }
  612.             {    p1.h p2.h gt
  613.                 {    p1.h roletextwidth 5 add add p1.v 0 sub branchQualTW 0 ne { 14 sub } if }
  614.                 {    p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  615.             } ifelse
  616.         } ifelse
  617.     } ifelse
  618.     moveto branchRole show
  619.     /p1.h pntArray 1 get def
  620.     /p1.v pntArray 0 get def
  621.     /p2.h pntArray 3 get def
  622.     /p2.v pntArray 2 get def
  623.     /multtextwidth branchMultText stringwidth pop def
  624.  
  625.     p1.h p2.h eq
  626.     { p1.v p2.v le
  627.         {    p1.h multtextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  628.         {    p1.h multtextwidth 5 add sub p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  629.      }
  630.      { p1.v p2.v eq
  631.             { p1.h p2.h gt
  632.                     { p1.h multtextwidth 5 add sub branchQualTW 0 ne { branchQualTW 9 add sub } if p1.v     4 add }
  633.                     { p1.h 5 add branchQualTW 0 ne { branchQualTW 7 add add } if p1.v 4 add } ifelse
  634.             }
  635.             { p1.v p2.v le
  636.                     { p1.h p2.h gt
  637.                             { p1.h multtextwidth 5 add sub p1.v 4 add branchQualTW 0 ne { 14 add } if }
  638.                             { p1.h 5 add p1.v 4 add branchQualTW 0 ne { 14 add } if } ifelse
  639.                     }
  640.                     { p1.h p2.h gt
  641.                             { p1.h multtextwidth 5 add sub p1.v 10 sub branchQualTW 0 ne { 14 sub } if }
  642.                             { p1.h 5 add p1.v 10 sub branchQualTW 0 ne { 14 sub } if } ifelse
  643.                     } ifelse
  644.             } ifelse
  645.     } ifelse
  646.     moveto
  647.     branchMult 3 eq {
  648.         branchMultText show
  649.     }if
  650.     end
  651. } def
  652.  
  653. /drawAggr    % [ pointn ... point1 noOfPoints branchRole branchMultText branchMult ] noOfBranches pointn ... point1 noOfPoints baseRole baseMultText baseMult qualPos qualifier name byvalue diamondx diamondy
  654. {
  655.     70 dict begin
  656.     Monaco9 setfont
  657.  
  658.     /diay exch def
  659.     /diax exch def
  660.     /byvalue exch def
  661.     /name exch def /qualifier exch def /qualPos exch def /baseMult exch def /baseMultText exch def 
  662.     /baseRole exch def
  663.     /noOfStemPoints exch def
  664.     /stemArray noOfStemPoints 2 mul array def
  665.     /index 0 def
  666.     {
  667.         index noOfStemPoints 2 mul eq { exit } if
  668.         stemArray index 3 -1 roll put
  669.         /index index 1 add def
  670.     } loop
  671.  
  672. % Get the qualifier's position
  673.     
  674.     /qualTW qualifier stringwidth pop def
  675.     /p1.h stemArray noOfStemPoints 1 sub 2 mul 1 add get def
  676.     /p1.v stemArray noOfStemPoints 1 sub 2 mul get def
  677.     /connect.h p1.h def
  678.     /connect.v p1.v def
  679.     qualPos 1 eq
  680.     {    % to the left of the first point
  681.         /connect.h connect.h diamondWidth 0.5 add add def
  682.         /p1.h connect.h qualTW 5 add sub def
  683.         /p1.v connect.v 3 sub def 
  684.     } if
  685.     qualPos 2 eq
  686.     {    % above the first point
  687.         /connect.v connect.v diamondWidth 1 add sub def
  688.         /p1.h connect.h qualTW 2 div sub def
  689.         /p1.v connect.v 4 add def 
  690.     } if
  691.     qualPos 3 eq
  692.     {    % to the right of the first point
  693.         /connect.h connect.h diamondWidth sub def
  694.         /p1.h connect.h 6 add def
  695.         /p1.v connect.v 3 sub def 
  696.     } if
  697.     qualPos 4 eq
  698.     {    % below the first point
  699.         /connect.v connect.v diamondWidth 0.5 add add def
  700.         /p1.h connect.h qualTW 2 div sub def
  701.         /p1.v connect.v 10 sub def
  702.     } if
  703.     /qualText.h p1.h def
  704.     /qualText.v p1.v def
  705.  
  706.     /lineConnect.h connect.h def
  707.     /lineConnect.v connect.v def
  708.  
  709. % Determine the qualifiers rectangle size
  710.     qualTW 0 ne
  711.     {
  712.         qualPos 1 eq
  713.         {    % to the left of the first class
  714.             /RectRight connect.h def
  715.             /RectLeft qualText.h 5 sub def
  716.             /lineConnect.h RectLeft def
  717.             /RectTop qualText.v 12 add def
  718.             /RectBottom RectTop 16 sub def
  719.         } if
  720.         qualPos 3 eq
  721.         {    % to the right of the first class
  722.             /RectLeft connect.h def
  723.             /RectRight qualText.h qualTW 5 add add def
  724.             /lineConnect.h RectRight def
  725.             /RectTop qualText.v 12 add def
  726.             /RectBottom RectTop 16 sub def
  727.         } if
  728.         qualPos 2 eq
  729.         {    % above the first point
  730.             /RectBottom connect.v def
  731.             /RectTop RectBottom 16 add def
  732.             /lineConnect.v RectTop def
  733.             /RectLeft qualText.h 4 sub def
  734.             /RectRight RectLeft qualTW 9 add add def
  735.         } if
  736.         qualPos 4 eq
  737.         {    % below the first point
  738.             /RectTop connect.v def
  739.             /RectBottom RectTop 16 sub def
  740.             /lineConnect.v RectBottom def
  741.             /RectLeft qualText.h 4 sub def
  742.             /RectRight RectLeft qualTW add 9 add def
  743.         } if
  744.         RectLeft RectTop moveto
  745.         RectRight RectTop lineto
  746.         RectRight RectBottom lineto
  747.         RectLeft RectBottom lineto
  748.         closepath stroke
  749.         newpath
  750.         qualText.h qualText.v moveto
  751.         qualifier show
  752.     } if
  753.  
  754.     /noOfBranches exch def /branchesArray noOfBranches array def /index 0 def
  755.     {
  756.         index noOfBranches eq { exit } if
  757.         /branchMult exch def /branchMultText exch def
  758.         /branchRole exch def /noOfBranchPoints exch def
  759.  
  760.         noOfBranchPoints 0 ne {
  761.             /pntArray noOfBranchPoints 2 mul array def
  762.             /pntIndex 0 def
  763.             {
  764.                 pntIndex noOfBranchPoints 2 mul eq { exit } if
  765.                 pntArray pntIndex 3 -1 roll put
  766.                 /pntIndex pntIndex 1 add def
  767.             } loop
  768.  
  769.             /branchArray 5 array def
  770.              branchArray 0 branchMult put branchArray 1 branchMultText put
  771.             branchArray 2 branchRole put branchArray 3 noOfBranchPoints put
  772.             branchArray 4 pntArray put
  773.          }
  774.          {
  775.              /branchArray 4 array def
  776.             branchArray 0 branchMult put branchArray 1 branchMultText put
  777.             branchArray 2 branchRole put branchArray 3 noOfBranchPoints put
  778.         } ifelse
  779.         branchesArray index branchArray put
  780.         /index index 1 add def
  781.     } loop
  782.     newpath 1 setlinewidth 0 setgray
  783.     /index 0 def
  784.     {
  785.         index noOfStemPoints eq { exit } if
  786.         stemArray index 2 mul 1 add get stemArray index 2 mul get
  787.         index noOfStemPoints 1 sub eq { pop pop lineConnect.h lineConnect.v } if
  788.         index 0 eq { moveto }{ lineto } ifelse
  789.         /index index 1 add def
  790.     } loop
  791.     branchesArray
  792.     {
  793.         /branch exch def /branchMult branch 0 get def
  794.         /branchMultText branch 1 get def /noOfPoints branch 3 get def
  795.         noOfPoints 0 ne {
  796.             /pntArray branch 4 get def
  797.             /index 0 def
  798.             {
  799.                 index noOfPoints eq { exit } if
  800.                 pntArray index 2 mul 1 add get pntArray index 2 mul get
  801.                 index 0 eq { moveto }{ lineto } ifelse
  802.                 /index index 1 add def
  803.             } loop
  804.         } if
  805.     }forall
  806.     stroke
  807.     branchesArray
  808.     {
  809.         /branch exch def
  810.         /branchMult branch 0 get def /branchMultText branch 1 get def
  811.         /branchRole branch 2 get def /noOfPoints branch 3 get def
  812.         noOfPoints 0 ne {
  813.             /pntArray branch 4 get def
  814.             newpath
  815.             /p1.h pntArray 1 get def /p1.v pntArray 0 get def
  816.             /p2.h pntArray 3 get def /p2.v pntArray 2 get def
  817.         }
  818.         {
  819.             newpath
  820.             /p1.h stemArray 1 get def /p1.v stemArray 0 get def
  821.             /p2.h stemArray 3 get def /p2.v stemArray 2 get def
  822.         } ifelse
  823.  
  824.         0 setgray
  825.  
  826.         p1.h p1.v
  827.         branchMult 1 eq {
  828.             % hollow circle
  829.             pointSize 0.5 sub 0 360 arc stroke
  830.             p1.h p1.v
  831.             pointSize 1 sub 0 360 arc 1 setgray fill
  832.         } if
  833.         branchMult 2 eq {
  834.             % filled circle
  835.             pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  836.         } if
  837.  
  838.         0 setgray
  839.         /roletextwidth branchRole stringwidth pop def
  840.  
  841.         p1.h p2.h eq
  842.         {    p1.v p2.v le
  843.             {    p1.h 5 add    p1.v 4 add }{ p1.h 5 add p1.v 10 sub } ifelse
  844.         }
  845.         { p1.v p2.v eq
  846.             {    p1.h p2.h gt
  847.                 { p1.h roletextwidth 5 add sub p1.v 10 sub }{ p1.h 5 add p1.v 10 sub } ifelse
  848.             }
  849.             {    p1.v p2.v le
  850.                 {    p1.h p2.h gt
  851.                     {    p1.h roletextwidth 5 add sub p1.v 4 add }{    p1.h 5 add p1.v 4 add } ifelse
  852.                 }
  853.                 {    p1.h p2.h gt
  854.                     {    p1.h roletextwidth 5 add add p1.v 0 sub }
  855.                     {    p1.h 5 add p1.v 10 sub } ifelse
  856.                 } ifelse
  857.             } ifelse
  858.         } ifelse
  859.         moveto branchRole show
  860.  
  861.         noOfPoints 0 ne {
  862.             /pntArray branch 4 get def
  863.             newpath
  864.             /p1.h pntArray 1 get def /p1.v pntArray 0 get def
  865.             /p2.h pntArray 3 get def /p2.v pntArray 2 get def
  866.         }
  867.         {
  868.             newpath
  869.             /p1.h stemArray 1 get def /p1.v stemArray 0 get def
  870.             /p2.h stemArray 3 get def /p2.v stemArray 2 get def
  871.         } ifelse
  872.         /multtextwidth branchMultText stringwidth pop def
  873.         0 setgray
  874.  
  875.         p1.h p2.h eq
  876.         { p1.v p2.v le
  877.             {    p1.h multtextwidth 5 add sub p1.v 4 add }
  878.             {    p1.h multtextwidth 5 add sub p1.v 10 sub }     ifelse
  879.         }
  880.         { p1.v p2.v eq
  881.             { p1.h p2.h gt
  882.                 { p1.h multtextwidth 5 add sub p1.v 4 add }{ p1.h 5 add p1.v 4 add } ifelse
  883.             }
  884.             { p1.v p2.v le
  885.                 { p1.h p2.h gt
  886.                     { p1.h multtextwidth 5 add sub p1.v 4 add }{ p1.h 5 add p1.v 4 add } ifelse
  887.                 }
  888.                 { p1.h p2.h gt
  889.                     { p1.h multtextwidth 5 add sub p1.v 10 sub }{ p1.h 5 add p1.v 10 sub } ifelse
  890.                 } ifelse
  891.             } ifelse
  892.         } ifelse
  893.         moveto
  894.         branchMult 3 eq {
  895.             branchMultText show
  896.         }if
  897.  
  898.     }forall
  899.     stroke
  900.  
  901.     0 setgray
  902.     /p1.h stemArray noOfStemPoints 1 sub 2 mul 1 add get def
  903.     /p1.v stemArray noOfStemPoints 1 sub 2 mul get def
  904.     /p2.h stemArray noOfStemPoints 2 sub 2 mul 1 add get def
  905.     /p2.v stemArray noOfStemPoints 2 sub 2 mul get def
  906.     /roletextwidth baseRole stringwidth pop def
  907.  
  908.     p1.h p2.h eq
  909.     { p1.v p2.v le
  910.         { p1.h 5 add p1.v 1 sub qualTW 0 ne { 14 add } if }
  911.         { p1.h 5 add p1.v 1 sub qualTW 0 ne { 14 sub } if } ifelse
  912.     }
  913.     { p1.v p2.v eq
  914.         { p1.h p2.h gt
  915.                 { p1.h roletextwidth 1 sub sub qualTW 0 ne { qualTW 9 add sub } if p1.v 10 sub }
  916.                 { p1.h 1 sub qualTW 0 ne { qualTW 7 add add } if p1.v 10 sub } ifelse
  917.         }
  918.         {    p1.v p2.v le
  919.             {    p1.h p2.h gt
  920.                 { p1.h roletextwidth 5 add sub p1.v 4 add qualTW 0 ne { 14 add } if }
  921.                 { p1.h 6 add p1.v 4 add qualTW 0 ne { 14 add } if } ifelse
  922.             }
  923.             {    p1.h p2.h gt
  924.                 { p1.h roletextwidth 5 add sub p1.v 10 sub qualTW 0 ne { 14 sub } if }
  925.                 { p1.h 6 add p1.v 10 sub qualTW 0 ne { 14 sub } if } ifelse
  926.             } ifelse
  927.         } ifelse
  928.     } ifelse
  929.     moveto baseRole show
  930.  
  931.     newpath
  932.     p1.h p2.h eq
  933.     { p1.v p2.v le
  934.             { p1.h p1.v 3 add qualTW 0 ne { 15 add } if }
  935.             { p1.h p1.v 3 sub qualTW 0 ne { 16 sub } if } ifelse
  936.     }
  937.     { p1.v p2.v eq
  938.             { p1.h p2.h gt
  939.                     { p1.h 2 sub qualTW 0 ne { qualTW 10 add sub } if p1.v }
  940.                     { p1.h 2 add qualTW 0 ne { qualTW 12 add add } if p1.v } ifelse
  941.             }
  942.             { p1.v p2.v le
  943.                     { p1.h p2.h gt
  944.                             { p1.h pointSize 5 add sub p1.v 4 add qualTW 0 ne { 15 add } if }
  945.                             { p1.h 5 add p1.v 4 add qualTW 0 ne { 15 add } if } ifelse
  946.                     }
  947.                     { p1.h p2.h gt
  948.                             { p1.h pointSize 5 add sub p1.v 10 sub qualTW 0 ne { 15 sub } if }
  949.                             { p1.h 5 add p1.v 10 sub qualTW 0 ne { 15 sub } if } ifelse
  950.                     } ifelse
  951.             } ifelse
  952.     } ifelse
  953.     /y exch def
  954.     /x exch def
  955.     x y
  956.     baseMult 1 eq {
  957.         % hollow circle
  958.         pointSize 0.5 sub 0 360 arc stroke
  959.         x y
  960.         pointSize 1 sub 0 360 arc 1 setgray fill
  961.     } if
  962.     baseMult 2 eq {
  963.         % filled circle
  964.         pointSize 0.5 sub 0 360 arc gsave stroke grestore 0 setgray fill
  965.     } if
  966.  
  967.     /multtextwidth baseMultText stringwidth pop def
  968.  
  969.     p1.h p2.h eq
  970.     { p1.v p2.v le
  971.             {    p1.h multtextwidth 5 add sub p1.v 1 sub qualTW 0 ne { 14 add } if }
  972.             {    p1.h multtextwidth 5 add sub p1.v 1 sub qualTW 0 ne { 14 sub } if }     ifelse
  973.     }
  974.     { p1.v p2.v eq
  975.             { p1.h p2.h gt
  976.                     { p1.h multtextwidth 1 sub sub qualTW 0 ne { qualTW 9 add sub } if p1.v 4 add }
  977.                     { p1.h 1 sub qualTW 0 ne { qualTW 7 add add } if p1.v 4 add } ifelse
  978.             }
  979.             { p1.v p2.v le
  980.                     { p1.h p2.h gt
  981.                             { p1.h multtextwidth 5 add sub p1.v 4 add qualTW 0 ne { 14 add } if }
  982.                             { p1.h 5 add p1.v 4 add qualTW 0 ne { 14 add } if } ifelse
  983.                     }
  984.                     { p1.h p2.h gt
  985.                             { p1.h multtextwidth 5 add sub p1.v 10 sub qualTW 0 ne { 14 sub } if }
  986.                             { p1.h 5 add p1.v 10 sub qualTW 0 ne { 14 sub } if } ifelse
  987.                     } ifelse
  988.             } ifelse
  989.     } ifelse
  990.     moveto
  991.     baseMult 3 eq {
  992.         baseMultText show
  993.     } if
  994.  
  995.     newpath 1 setlinewidth
  996.     qualTW 0 ne
  997.     {
  998.         qualPos 1 eq
  999.         {
  1000.             /diax diax qualTW 9 add sub def
  1001.         } if
  1002.         qualPos 2 eq
  1003.         {
  1004.             /diay diay 16 add def
  1005.         } if
  1006.         qualPos 3 eq
  1007.         {
  1008.             /diax diax qualTW 11 add add def
  1009.         } if
  1010.         qualPos 4 eq
  1011.         {
  1012.             /diay diay 16 sub def
  1013.         } if
  1014.     } if
  1015.  
  1016.     diax diamondWidth 2 div sub 0.5 add diay moveto
  1017.  
  1018.     diamondWidth 2 div 1 sub diamondWidth 2 div 1 sub rlineto
  1019.     diamondWidth 2 div 1 sub diamondWidth 2 div 1 sub neg rlineto
  1020.     diamondWidth 2 div 1 sub neg diamondWidth 2 div 1 sub neg rlineto
  1021.     closepath
  1022.     byvalue 0 eq { 1 setgray }{ 0 setgray } ifelse fill
  1023.  
  1024.     newpath 1 setlinewidth 0 setgray
  1025.     diax diamondWidth 2 div sub diay moveto
  1026.  
  1027.     diamondWidth 2 div 0.5 sub diamondWidth 2 div 0.5 sub rlineto
  1028.     diamondWidth 2 div 0.5 sub diamondWidth 2 div 0.5 sub neg rlineto
  1029.     diamondWidth 2 div 0.5 sub neg diamondWidth 2 div 0.5 sub neg rlineto
  1030.     closepath stroke
  1031.  
  1032.  
  1033.     end
  1034. } def
  1035.  
  1036. /arrowdict 15 dict def
  1037. arrowdict begin
  1038. /mtrx matrix def
  1039. end
  1040.  
  1041. /drawArrow %     tailx taily tipx tipy halfthickness halfheadthickness headlength dashed filled drawArrow
  1042. { arrowdict begin
  1043.     /filled exch def
  1044.     /dashed exch def
  1045.     /headlength exch def
  1046.     /halfheadthickness exch 2 div def
  1047.     /halfthickness exch 2 div def
  1048.     /tipy exch def /tipx exch def
  1049.     /taily exch def /tailx exch def
  1050.  
  1051.     /dx tipx tailx sub def
  1052.     /dy tipy taily sub def
  1053.     /arrowlength dx dx mul dy dy mul add sqrt def
  1054.     /angle dy dx atan def
  1055.     /arrowlength arrowlength headlength add def
  1056.     /base arrowlength headlength sub def
  1057.     /savematrix mtrx currentmatrix def
  1058.     tailx taily translate
  1059.     angle rotate
  1060.     base halfthickness neg moveto
  1061.     base halfheadthickness neg lineto
  1062.     arrowlength 0 lineto
  1063.     base halfheadthickness lineto
  1064.     base halfthickness lineto
  1065.     closepath
  1066.     filled true eq { fill }{ gsave 1 setgray fill grestore stroke } ifelse
  1067.     savematrix setmatrix
  1068.     newpath 1 setlinewidth
  1069.     tailx taily translate
  1070.     angle rotate
  1071.     dashed true eq { [3] 0 setdash }if
  1072.     0 0 moveto base 0 lineto stroke
  1073.     dashed true eq { [] 0 setdash }if
  1074.     savematrix setmatrix
  1075.     end
  1076. } def
  1077.  
  1078. /genarrowdict 15 dict def
  1079. genarrowdict begin
  1080. /mtrx matrix def
  1081. end
  1082.  
  1083. /drawGenArrow %     tailx taily tipx tipy halfthickness halfheadthickness headlength dashed filled drawGenArrow
  1084. { genarrowdict begin
  1085.     /filled exch def
  1086.     /dashed exch def
  1087.     /headlength exch def
  1088.     /halfheadthickness exch 2 div def
  1089.     /halfthickness exch 2 div def
  1090.     /tipy exch def /tipx exch def
  1091.     /taily exch def /tailx exch def
  1092.  
  1093.     /dx tipx tailx sub def
  1094.     /dy tipy taily sub def
  1095.     /arrowlength dx dx mul dy dy mul add sqrt halfthickness sub def
  1096.     /angle dy dx atan def
  1097.     /base arrowlength headlength sub def
  1098.     /savematrix mtrx currentmatrix def
  1099.     tailx taily translate
  1100.     angle rotate
  1101.     base halfthickness neg moveto
  1102.     base halfheadthickness neg lineto
  1103.     arrowlength 0 lineto
  1104.     base halfheadthickness lineto
  1105.     base halfthickness lineto
  1106.     closepath
  1107.     filled true eq { fill }{ gsave 1 setgray fill grestore stroke } ifelse
  1108.     savematrix setmatrix
  1109.     newpath 1 setlinewidth
  1110.     tailx taily translate
  1111.     angle rotate
  1112.     dashed true eq { [3] 0 setdash }if
  1113.     0 0 moveto base 0 lineto stroke
  1114.     dashed true eq { [] 0 setdash }if
  1115.     savematrix setmatrix
  1116.     end
  1117. } def
  1118.  
  1119. % [ pointn ... point1 noOfPoints branchRole branchMultText branchMult ] noOfBranches pointn ... point1 noOfPoints baseRole baseMultText baseMult qualPos qualifier name pyramidorientation pyramidx pyramidy omtNotation
  1120. /drawGen
  1121. {
  1122.     50 dict begin
  1123.     Monaco9 setfont
  1124.  
  1125.     /omtNotation exch def
  1126.     /pyry exch def
  1127.     /pyrx exch def
  1128.     /orient exch def
  1129.     /name exch def
  1130.       /noOfStemPoints exch def
  1131.     /stemArray noOfStemPoints 2 mul array def
  1132.     /index 0 def
  1133.     {
  1134.         index noOfStemPoints 2 mul eq { exit } if
  1135.         stemArray index 3 -1 roll put
  1136.         /index index 1 add def
  1137.     } loop
  1138.  
  1139.     /noOfBranches exch def
  1140.     /branchesArray noOfBranches array def
  1141.  
  1142.     /index 0 def
  1143.     {
  1144.         index noOfBranches eq { exit } if
  1145.  
  1146.         /branchMult exch def /branchMultText exch def
  1147.         /branchRole exch def /noOfBranchPoints exch def
  1148.  
  1149.         noOfBranchPoints 0 ne {
  1150.             /pntArray noOfBranchPoints 2 mul array def
  1151.             /pntIndex 0 def
  1152.             {
  1153.                 pntIndex noOfBranchPoints 2 mul eq { exit } if
  1154.                 pntArray pntIndex 3 -1 roll put
  1155.                 /pntIndex pntIndex 1 add def
  1156.             } loop
  1157.  
  1158.             /branchArray 2 array def
  1159.           branchArray 0 noOfBranchPoints put branchArray 1 pntArray put
  1160.         }
  1161.         {
  1162.             /branchArray 1 array def
  1163.           branchArray 0 noOfBranchPoints put
  1164.         } ifelse
  1165.         branchesArray index branchArray put
  1166.         /index index 1 add def
  1167.     } loop
  1168.     newpath 1 setlinewidth 0 setgray
  1169.     /index 0 def
  1170.     {
  1171.         index noOfStemPoints eq { exit } if
  1172.         stemArray index 2 mul 1 add get stemArray index 2 mul get
  1173.         index 0 eq { moveto }{ lineto } ifelse
  1174.         /index index 1 add def
  1175.     } loop
  1176.  
  1177.     branchesArray
  1178.     {
  1179.         /branch exch def
  1180.         /noOfPoints branch 0 get def
  1181.         noOfPoints 0 ne {
  1182.             /pntArray branch 1 get def
  1183.             /index 0 def
  1184.             {
  1185.                 index noOfPoints eq { exit } if
  1186.                 pntArray index 2 mul 1 add get pntArray index 2 mul get
  1187.                 index 0 eq { moveto }{ lineto } ifelse
  1188.                 /index index 1 add def
  1189.             } loop
  1190.         }if
  1191.     }forall
  1192.     stroke
  1193.  
  1194.     newpath
  1195.     pyrx pyry moveto
  1196.  
  1197.     omtNotation 1 eq {
  1198.         orient 0 eq {
  1199.             pyramidWidth 2 div 1.6 sub 0 rlineto
  1200.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub rlineto
  1201.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub neg rlineto
  1202.         } if
  1203.         orient 2 eq {
  1204.             0 pyramidWidth 2 div 1.6 sub rlineto
  1205.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub neg rlineto
  1206.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub neg rlineto
  1207.         } if
  1208.         orient 4 eq {
  1209.             pyramidWidth 2 div 1.6 sub neg 0 rlineto
  1210.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub neg rlineto
  1211.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub rlineto
  1212.         } if
  1213.         orient 6 eq {
  1214.             0 pyramidWidth 2 div 1.6 sub neg rlineto
  1215.             pyramidWidth 2 div 1.6 sub pyramidWidth 2 div 1.6 sub rlineto
  1216.             pyramidWidth 2 div 1.6 sub neg pyramidWidth 2 div 1.6 sub rlineto
  1217.         } if
  1218.         closepath 1 setgray fill
  1219.  
  1220.         newpath 1 setlinewidth 0 setgray
  1221.         pyrx pyry moveto
  1222.  
  1223.         orient 0 eq {
  1224.             pyramidWidth 2 div 0.5 sub 0 rlineto
  1225.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub rlineto
  1226.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub neg rlineto
  1227.         } if
  1228.         orient 2 eq {
  1229.             0 pyramidWidth 2 div 0.5 sub rlineto
  1230.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub neg rlineto
  1231.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub neg rlineto
  1232.         } if
  1233.         orient 4 eq {
  1234.             pyramidWidth 2 div 0.5 sub neg 0 rlineto
  1235.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub neg rlineto
  1236.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub rlineto
  1237.         } if
  1238.         orient 6 eq {
  1239.             0 pyramidWidth 2 div 0.5 sub neg rlineto
  1240.             pyramidWidth 2 div 0.5 sub pyramidWidth 2 div 0.5 sub rlineto
  1241.             pyramidWidth 2 div 0.5 sub neg pyramidWidth 2 div 0.5 sub rlineto
  1242.         } if
  1243.         closepath stroke
  1244.     }
  1245.     {
  1246.         /i noOfStemPoints 2 mul def
  1247.         stemArray i 3 sub get stemArray i 4 sub get stemArray i 1 sub get stemArray i 2 sub get 1 15 20 false false drawGenArrow
  1248.     } ifelse
  1249.     
  1250.     end
  1251. } def
  1252.  
  1253.  
  1254. /drawEventBox        % ulc.x ulc.y height
  1255. {
  1256.     50 dict begin
  1257.  
  1258.     /height exch def /ulcy exch def /ulcx exch def
  1259.  
  1260.     newpath 1 setlinewidth
  1261.     ulcx ulcy moveto eventBoxWidth 0 rlineto 0 height neg rlineto
  1262.     eventBoxWidth neg 0 rlineto closepath
  1263.     gsave stroke grestore
  1264.     1 setgray fill
  1265.     0 setgray fill
  1266.     end
  1267. } def
  1268.  
  1269. /drawEventThread    % ulc.x ulc.y height name
  1270. {
  1271.     50 dict begin
  1272.  
  1273.     /name exch def /height exch def /ulcy exch def /ulcx exch def
  1274.  
  1275.     newpath 1 setlinewidth
  1276.     Monaco10 setfont
  1277.     1 setlinewidth ulcx ulcy moveto 0 height neg rlineto stroke
  1278.     ulcx name stringwidth pop 2 div sub ulcy 10 add moveto name show
  1279.     end
  1280. } def
  1281.  
  1282. /drawEventEvent        % fulcx fulcy flrcx flrcy ulcx ulcy lrcx lrcy name dashed
  1283. {
  1284.     50 dict begin
  1285.  
  1286.     /dashed exch def /name exch def /lrcy exch def /lrcx exch def
  1287.     /ulcy exch def /ulcx exch def
  1288.     /flrcy exch def /flrcx exch def
  1289.     /fulcy exch def /fulcx exch def
  1290.  
  1291.     Monaco9 setfont
  1292.     newpath 1 setlinewidth
  1293.     ulcx ulcy lrcx lrcy 1 5 5 dashed true drawArrow
  1294.  
  1295.     fulcx flrcx gt
  1296.     {    % above to the left of p1
  1297.         /textx fulcx name stringwidth pop 3 add sub def
  1298.         /texty fulcy 2 add def
  1299.     }
  1300.     {    % above to the right of p1
  1301.         /textx fulcx 4 add def
  1302.         /texty fulcy 2 add def
  1303.     }ifelse
  1304.     textx texty moveto
  1305.     name show
  1306.     end
  1307. } def
  1308. /drawSupp        % pointn ... point1 noOfPoints name drawSupp
  1309. {
  1310.     50 dict begin
  1311.  
  1312.     /name exch def
  1313.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  1314.     {
  1315.         index noOfPoints 2 mul eq { exit } if
  1316.         pntArray index 3 -1 roll put
  1317.         /index index 1 add def
  1318.     } loop
  1319.  
  1320.     Monaco9 setfont
  1321.     [3] 0 setdash
  1322.     newpath 1 setlinewidth
  1323.     noOfPoints 2 gt {
  1324.         /index 0 def
  1325.         {
  1326.             index noOfPoints 1 sub eq { exit } if
  1327.             /p1.h pntArray index 2 mul 1 add get def
  1328.             /p1.v pntArray index 2 mul get def
  1329.             /p2.h pntArray index 1 add 2 mul 1 add get def
  1330.             /p2.v pntArray index 1 add 2 mul get def
  1331.             p1.h p1.v moveto p2.h p2.v lineto stroke
  1332.             /index index 1 add def
  1333.         } loop
  1334.     } if
  1335.  
  1336.     /p1.h pntArray 1 get def
  1337.     /p1.v pntArray 0 get def
  1338.     /p2.h pntArray 3 get def
  1339.     /p2.v pntArray 2 get def
  1340.     p1.h p2.h eq
  1341.     {
  1342.         p1.v p2.v gt
  1343.         {
  1344.             /p1.v p1.v 5 sub def
  1345.         }
  1346.         {
  1347.             /p1.v p1.v 5 add def
  1348.         }ifelse
  1349.     }
  1350.     {
  1351.         p1.h p2.h gt
  1352.         {
  1353.             /p1.h p1.h 5 sub def
  1354.         }
  1355.         {
  1356.             /p1.h p1.h 5 add def
  1357.         }ifelse
  1358.     } ifelse
  1359.     [] 0 setdash
  1360.     p2.h p2.v p1.h p1.v 1 5 5 true true drawArrow
  1361.  
  1362.     end
  1363. } def
  1364.  
  1365. /fourpops { pop pop pop pop } def
  1366. /drawRoundedBox % ulcx ulcy width height
  1367. {
  1368.     50 dict begin
  1369.  
  1370.     /height exch def /width exch def
  1371.     /ulcy exch def /ulcx exch def
  1372.  
  1373.     /lrcx ulcx width add def /lrcy ulcy height sub def
  1374.  
  1375.     ulcx lrcy 10 add moveto
  1376.     ulcx lrcy lrcx lrcy 5 arcto fourpops
  1377.     lrcx lrcy lrcx ulcy 5 arcto fourpops
  1378.     lrcx ulcy ulcx ulcy 5 arcto fourpops
  1379.     ulcx ulcy ulcx lrcy 5 arcto fourpops
  1380.     closepath
  1381.     gsave 1 setgray fill grestore stroke
  1382.     end
  1383. } def
  1384.  
  1385. /drawStateBox % actionn eventn .. action1 event1 noOfEvents exitlinen exitline1 noOfExitLines dolinen doline1 noOfDoLines entrylinen entryline1 noOfEntryLines name
  1386. {
  1387.     50 dict begin
  1388.  
  1389.     /boxheight 30 def
  1390.     /boxwidth 60 def
  1391.     /name exch def 
  1392.  
  1393. %
  1394. % Get all the entry/ lines and store them in entryLineArray
  1395. %
  1396.     /noOfEntryLines exch def
  1397.     /entryLineWidth 0 def     /entryHeight 0 def
  1398.     noOfEntryLines 0 ne
  1399.     { 
  1400.         /entryLineArray noOfEntryLines array def
  1401.         /entryLineIndex 0 def
  1402.         {
  1403.             entryLineIndex noOfEntryLines eq { exit } if
  1404.             entryLineArray entryLineIndex 3 -1 roll put
  1405.             /entryLineIndex entryLineIndex 1 add def
  1406.         } loop
  1407.         /entryHeight entryLineIndex 12 mul def
  1408.         /rubrikwidth MonacoI9 setfont (entry/ ) stringwidth pop def
  1409.         Monaco9 setfont
  1410.         entryLineArray
  1411.         {
  1412.             stringwidth pop dup rubrikwidth add 16 add
  1413.             entryLineWidth gt { /entryLineWidth exch def }{ pop } ifelse
  1414.         } forall
  1415.     } if
  1416.  
  1417. %
  1418. % Get all the do: lines and store them in doLineArray
  1419. %
  1420.     /noOfDoLines exch def
  1421.     /doLineWidth 0 def     /doHeight 0 def
  1422.     noOfDoLines 0 ne
  1423.     { 
  1424.         /doLineArray noOfDoLines array def
  1425.         /doLineIndex 0 def
  1426.         {
  1427.             doLineIndex noOfDoLines eq { exit } if
  1428.             doLineArray doLineIndex 3 -1 roll put
  1429.             /doLineIndex doLineIndex 1 add def
  1430.         } loop
  1431.         /doHeight doLineIndex 12 mul def
  1432.         /rubrikwidth Monaco9 setfont (do: ) stringwidth pop def
  1433.         doLineArray
  1434.         {
  1435.             stringwidth pop dup rubrikwidth add 16 add
  1436.             doLineWidth gt { /doLineWidth exch def }{ pop } ifelse
  1437.         } forall
  1438.     } if
  1439.  
  1440. %
  1441. % Get all the exit/ lines and store them in exitLineArray
  1442. %
  1443.     /noOfExitLines exch def
  1444.     /exitLineWidth 0 def     /exitHeight 0 def
  1445.     noOfExitLines 0 ne
  1446.     { 
  1447.         /exitLineArray noOfExitLines array def
  1448.         /exitLineIndex 0 def
  1449.         {
  1450.             exitLineIndex noOfExitLines eq { exit } if
  1451.             exitLineArray exitLineIndex 3 -1 roll put
  1452.             /exitLineIndex exitLineIndex 1 add def
  1453.         } loop
  1454.         /exitHeight exitLineIndex 12 mul def
  1455.         /rubrikwidth MonacoI9 setfont (exit/ ) stringwidth pop def
  1456.         Monaco9 setfont
  1457.         exitLineArray
  1458.         {
  1459.             stringwidth pop dup rubrikwidth add 16 add
  1460.             exitLineWidth gt { /exitLineWidth exch def }{ pop } ifelse
  1461.         } forall
  1462.     } if
  1463.  
  1464. %
  1465. % Get all the event/ lines and store each event in the eventsArray
  1466. % Each element of the eventsArray is another array where the first
  1467. % item holds the number of lines (following items)
  1468. %
  1469.     /noOfEvents exch def
  1470.     /eventHeight 0 def
  1471.     noOfEvents 0 ne
  1472.     { 
  1473.         /eventsArray noOfEvents array def
  1474.         /eventIndex 0 def
  1475.         {
  1476.             eventIndex noOfEvents eq { exit } if
  1477.             /noOfEventLines exch def
  1478.             /eventArray noOfEventLines 2 add array def
  1479.             eventArray 0 noOfEventLines put
  1480.             /lineIndex 1 def
  1481.             {
  1482.                 lineIndex noOfEventLines 2 add eq { exit } if
  1483.                 eventArray lineIndex 3 -1 roll put
  1484.                 /lineIndex lineIndex 1 add def
  1485.             } loop
  1486.             eventsArray eventIndex eventArray put
  1487.             /eventIndex eventIndex 1 add def
  1488.         } loop
  1489.  
  1490.         /eventLineWidth 0 def
  1491.  
  1492.         eventsArray
  1493.         {
  1494.             /ar exch def
  1495.             /noOfLines ar 0 get def
  1496.             /eventHeight eventHeight noOfLines add def
  1497.             /rubrikwidth ar noOfLines 1 add get MonacoI9 setfont stringwidth pop def
  1498.          Monaco9 setfont
  1499.             /item noOfLines def
  1500.             {
  1501.                 item 0 eq { exit } if
  1502.                 ar item get Monaco9 setfont stringwidth pop
  1503.                 rubrikwidth add 16 add dup
  1504.                 boxwidth gt { /boxwidth exch def }{ pop } ifelse
  1505.                 /item item 1 sub def
  1506.             } loop
  1507.         } forall
  1508.     /eventHeight eventHeight 10 mul def
  1509.     } if
  1510.  
  1511.     currentpoint /ulcy exch def /ulcx exch def
  1512.     /leftmargin currentpoint pop def /topmargin currentpoint exch pop def
  1513.  
  1514.     Monaco10 setfont
  1515.     name stringwidth pop dup 8 add
  1516.     boxwidth gt { /boxwidth exch def }{ pop } ifelse
  1517.  
  1518.     entryLineWidth boxwidth gt { /boxwidth entryLineWidth def } if
  1519.     doLineWidth boxwidth gt { /boxwidth doLineWidth def } if
  1520.     exitLineWidth boxwidth gt { /boxwidth exitLineWidth def } if
  1521.  
  1522.     30 exitHeight add doHeight add entryHeight add eventHeight add dup
  1523.     boxheight gt { /boxheight exch def }{ pop } ifelse
  1524.  
  1525. % Draw the name of the state
  1526.     Monaco10 setfont
  1527.     ulcx ulcy boxwidth boxheight drawRoundedBox
  1528.     ulcx boxwidth name stringwidth pop sub 2 div add
  1529.     ulcy 18 sub moveto name show
  1530.  
  1531.     /entryIndex 0 def
  1532.     entryHeight 0 ne
  1533.     {
  1534.         /item noOfEntryLines 1 sub def
  1535.         {
  1536.             item -1 eq { exit }if
  1537.             entryLineArray item get
  1538.             /item item 1 sub def
  1539.             ulcx 5 add ulcy 30 sub entryIndex 10 mul sub moveto
  1540.             entryIndex 0 eq { MonacoI9 setfont (entry/ ) show
  1541.                                                                 /leftmargin currentpoint pop ulcx 5 add sub def Monaco9 setfont }
  1542.                                                                 { leftmargin 0 rmoveto } ifelse
  1543.             show
  1544.             /entryIndex entryIndex 1 add def
  1545.         } loop
  1546.     } if
  1547.     Monaco9 setfont
  1548.     /doIndex 0 def
  1549.     doHeight 0 ne
  1550.     {
  1551.         /item noOfDoLines 1 sub def
  1552.         {
  1553.             item -1 eq { exit }if
  1554.             doLineArray item get
  1555.             /item item 1 sub def
  1556.             ulcx 5 add ulcy 30 sub doIndex 10 mul sub entryIndex 10 mul sub moveto
  1557.             doIndex 0 eq { (do: ) show /leftmargin currentpoint pop ulcx 5 add sub def }{ leftmargin 0 rmoveto } ifelse
  1558.             show
  1559.             /doIndex doIndex 1 add def
  1560.         } loop
  1561.     } if
  1562.  
  1563.     /eventIndex 0 def
  1564.     eventHeight 0 ne
  1565.     {
  1566.         /item noOfEvents 1 sub def
  1567.         {
  1568.             item -1 eq { exit }if
  1569.             /ar eventsArray item get def
  1570.             /item item 1 sub def
  1571.             /noOfLines ar 0 get def
  1572.             /lineIndex noOfLines 1 add def
  1573.             {
  1574.                 lineIndex 0 eq { exit } if
  1575.                 ar lineIndex get
  1576.                 ulcx 5 add ulcy 32 sub entryIndex 10 mul sub doIndex 10 mul sub eventIndex 10 mul sub moveto
  1577.                 lineIndex noOfLines 1 add eq
  1578.                 {
  1579.                     MonacoI9 setfont show ( ) show  /leftmargin currentpoint pop ulcx 5 add sub def
  1580.                     ar noOfLines get Monaco9 setfont show
  1581.                     /lineIndex lineIndex 2 sub def
  1582.                 }
  1583.                 {
  1584.                     leftmargin 0 rmoveto show
  1585.                     /lineIndex lineIndex 1 sub def
  1586.                 }ifelse
  1587.                 /eventIndex eventIndex 1 add def
  1588.             } loop
  1589.         } loop
  1590.     } if
  1591.  
  1592.     /exitIndex 0 def
  1593.     exitHeight 0 ne
  1594.     {
  1595.         /item noOfExitLines 1 sub def
  1596.         {
  1597.             item -1 eq { exit }if
  1598.             exitLineArray item get
  1599.             /item item 1 sub def
  1600.             ulcx 5 add ulcy 32 sub entryIndex 10 mul sub doIndex 10 mul sub eventIndex 10 mul sub exitIndex 10 mul sub moveto
  1601.             exitIndex 0 eq { MonacoI9 setfont (exit/ ) show
  1602.             /leftmargin currentpoint pop ulcx 5 add sub def
  1603.             Monaco9 setfont } { leftmargin 0 rmoveto }ifelse
  1604.             show
  1605.             /exitIndex exitIndex 1 add def
  1606.         } loop
  1607.     } if
  1608.     leftmargin boxwidth add topmargin boxheight sub
  1609.     end
  1610. } def
  1611.  
  1612. /drawStateEvent % [ pointn ... point1 ] noOfPoints eventtext
  1613.     50 dict begin
  1614.     Monaco9 setfont
  1615.  
  1616.     /eventtext exch def
  1617.  
  1618.     /noOfPoints exch def /pntArray noOfPoints 2 mul array def /index 0 def
  1619.     {
  1620.         index noOfPoints 2 mul eq { exit } if
  1621.         pntArray index 3 -1 roll put
  1622.         /index index 1 add def
  1623.     } loop
  1624.  
  1625.     newpath 1 setlinewidth 0 setgray
  1626.     /index 0 def
  1627.     {
  1628.         index noOfPoints eq { exit } if
  1629.         pntArray index 2 mul 1 add get pntArray index 2 mul get
  1630.         index 0 eq { moveto }{ lineto } ifelse
  1631.         /index index 1 add def
  1632.     } loop
  1633.     stroke
  1634.     pntArray noOfPoints 1 sub 2 mul 1 add get pntArray noOfPoints 1 sub 2 mul get
  1635.     pntArray noOfPoints 2 sub 2 mul 1 add get pntArray noOfPoints 2 sub 2 mul get
  1636.  
  1637. %
  1638. % Last line's x and y are on top of the stack
  1639. %
  1640.     /p1.v exch def
  1641.     /p1.h exch def
  1642.     /p2.v exch def
  1643.     /p2.h exch def
  1644.     /width eventtext stringwidth pop def
  1645.  
  1646.     p1.v p2.v eq
  1647.     {
  1648.         /p.v p1.v 7 add def
  1649.         p1.h p2.h lt
  1650.         {
  1651.             /p.h p1.h p2.h p1.h sub 2 div add  width 2 div   sub def
  1652.         }
  1653.         {
  1654.             /p.h p2.h p1.h p2.h sub 2 div add   width 2 div   sub def
  1655.         }ifelse
  1656.     }
  1657.     {
  1658.         p1.h p2.h eq
  1659.         {
  1660.             /p.h p1.h 5 add def
  1661.             p1.v p2.v ge
  1662.             {
  1663.                 /p.v p1.v p2.v p1.v sub 2 div add def
  1664.             }
  1665.             {
  1666.                 /p.v p2.v p1.v p2.v sub 2 div add def
  1667.             }ifelse
  1668.         }
  1669.         {
  1670.             p1.v p2.v ge
  1671.             {
  1672.                 /p.v  p1.v p2.v p1.v sub 2 div add def
  1673.             }
  1674.             {
  1675.                 /p.v  p2.v p1.v p2.v sub 2 div add def
  1676.             }ifelse
  1677.  
  1678.             p1.h p2.h lt
  1679.             {
  1680.                 /p.h  p1.h p2.h p1.h sub 2 div width 2 div sub add def
  1681.             }
  1682.             {
  1683.                 /p.h  p2.h p1.h p2.h sub 2 div width 2 div sub add def
  1684.             }ifelse
  1685.         }ifelse
  1686.     }ifelse
  1687.  
  1688.     MonacoI9 setfont
  1689.     p.h p.v moveto eventtext show
  1690.  
  1691.     pntArray 1 get pntArray 0 get
  1692.     /p1.v exch def /p1.h exch def
  1693.     pntArray 3 get pntArray 2 get
  1694.     /p2.v exch def /p2.h exch def
  1695.  
  1696.     p1.h p2.h eq
  1697.     {
  1698.         p1.v p2.v gt
  1699.         {
  1700.             /p1.v p1.v 5 sub def
  1701.         }
  1702.         {
  1703.             /p1.v p1.v 5 add def
  1704.         }ifelse
  1705.     }
  1706.     {
  1707.         p1.h p2.h gt
  1708.         {
  1709.             /p1.h p1.h 5 sub def
  1710.         }
  1711.         {
  1712.             /p1.h p1.h 5 add def
  1713.         }ifelse
  1714.     } ifelse
  1715.  p2.h p2.v p1.h p1.v 1 5 5 false true drawArrow
  1716.  
  1717.     end
  1718. } def
  1719.  
  1720. /drawNote %  linen line1 noOfLines width height drawNote
  1721. {
  1722.     50 dict begin
  1723.  
  1724.     /boxheight exch def
  1725.     /boxwidth exch def
  1726.  
  1727. %
  1728. % Get all the lines and store them in lineArray
  1729. %
  1730.     Monaco9 setfont
  1731.  
  1732.     /noOfLines exch def
  1733.     noOfLines 0 ne
  1734.     { 
  1735.         /lineArray noOfLines array def
  1736.         /lineIndex 0 def
  1737.         {
  1738.             lineIndex noOfLines eq { exit } if
  1739.             lineArray lineIndex 3 -1 roll put
  1740.             /lineIndex lineIndex 1 add def
  1741.         } loop
  1742.     } if
  1743.  
  1744.     currentpoint /ulcy exch def /ulcx exch def
  1745.  
  1746.     % compute max width of text lines
  1747.     /maxwidth 0 def
  1748.     noOfLines 0 ne
  1749.     {
  1750.         /item noOfLines 1 sub def
  1751.         {
  1752.             item -1 eq { exit }if
  1753.             lineArray item get
  1754.             stringwidth pop
  1755.             /width exch def
  1756.             maxwidth width lt { /maxwidth width def }if
  1757.             /item item 1 sub def
  1758.         } loop
  1759.     } if
  1760.     boxwidth maxwidth lt { /boxwidth maxwidth def }if
  1761.  
  1762.     % draw the box
  1763.     currentpoint boxwidth 0 rlineto
  1764.     0 boxheight neg rlineto
  1765.     boxwidth neg 0 rlineto closepath stroke
  1766.  
  1767.     % set clipping region
  1768.     gsave
  1769.     newpath
  1770.     ulcx 5 add ulcy moveto
  1771.     boxwidth 10 sub 0 rlineto
  1772.     0 boxheight neg rlineto
  1773.     boxwidth 10 sub neg 0 rlineto closepath clip
  1774.  
  1775.     /index 0 def
  1776.     noOfLines 0 ne
  1777.     {
  1778.         /item noOfLines 1 sub def
  1779.         {
  1780.             item -1 eq { exit }if
  1781.             lineArray item get
  1782.             /item item 1 sub def
  1783.             ulcx 5 add ulcy 12 sub index 10 mul sub moveto
  1784.             show
  1785.             /index index 1 add def
  1786.         } loop
  1787.     } if
  1788.     grestore
  1789.     newpath
  1790.     ulcx boxwidth add 14 sub ulcy moveto
  1791.     14 0 rlineto
  1792.     0 -10 rlineto closepath gsave stroke grestore 0.5 setgray fill
  1793.  
  1794.     2 setlinejoin
  1795.     ulcx boxwidth add 14 sub ulcy moveto
  1796.  
  1797.     ulcx boxwidth add 12 sub ulcy 3 sub        % x1, y1
  1798.     ulcx boxwidth add 11 sub ulcy 5 sub        % x2, y2
  1799.     ulcx boxwidth add 12 sub ulcy 10 sub    % x3, y3
  1800.     curveto
  1801.  
  1802.     ulcx boxwidth add 9 sub ulcy 8 sub    % x1, y1
  1803.     ulcx boxwidth add 4 sub ulcy 8 sub    % x2, y2
  1804.     ulcx boxwidth add ulcy 10 sub        % x3, y3
  1805.     curveto
  1806.  
  1807.     closepath gsave 1 setgray fill grestore 0 setgray stroke
  1808.     0 setlinejoin
  1809.  
  1810.     ulcx boxwidth add ulcy boxheight sub
  1811.  
  1812.     end
  1813. } def
  1814.  
  1815.  
  1816. /drawInitialState %  diameter x y drawInitialState
  1817. {
  1818.     50 dict begin
  1819.  
  1820.     /y exch def
  1821.     /x exch def
  1822.     /circleSize exch def
  1823.     newpath
  1824.     x circleSize 2 div add
  1825.     y circleSize 2 div sub
  1826.     circleSize 2 div
  1827.     0 360 arc
  1828.     closepath gsave stroke grestore fill
  1829.  
  1830.     end
  1831. } def
  1832.  
  1833. /drawFinalState %  diameter x y drawFinalState
  1834. {
  1835.     50 dict begin
  1836.  
  1837.     /y exch def
  1838.     /x exch def
  1839.     /circleSize exch def
  1840.     newpath
  1841.     x circleSize 2 div add
  1842.     y circleSize 2 div sub
  1843.     circleSize 2 div
  1844.     0 360 arc
  1845.     closepath stroke
  1846.     newpath
  1847.     x circleSize 2 div add
  1848.     y circleSize 2 div sub
  1849.     circleSize 2 div 3 sub
  1850.     0 360 arc
  1851.     closepath fill
  1852.  
  1853.     end
  1854. } def
  1855.  
  1856. newpath 1 setlinewidth
  1857.  
  1858.